package org.sith.gl.taskmanager.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;



public class HomePane extends AbstractVerticalPane {
    @Override
    protected void initData() {
        
        Button addUserButton = new Button("Add User");
        addUserButton.addClickHandler(new ChangePageClickHandler("addUser.jsp"));

        add(addUserButton);
        Button logoutButton = new Button("Logout");
        logoutButton.addClickHandler(new ChangePageClickHandler("logout"));
        add(logoutButton);
    }

    @Override
    protected String getPagePosition() {
        return "home";
    }

    private static class ChangePageClickHandler implements ClickHandler {
        private String path;

        private ChangePageClickHandler(String path) {
            this.path = path;
        }

        @Override
        public void onClick(ClickEvent clickEvent) {

            Window.Location.replace(GWT.getHostPageBaseURL()+path);
        }
    }
}
